package com.caesar;

import java.util.*;

/**
 * @author caesar
 * @date 2025/7/18
 * @Description:
 * @apiNote
 */
public class exer2 {
    public static void main(String[] args) {
        HashMap<Integer, ArrayList<String>> map = new HashMap<>();
        ArrayList<String> group1 = new ArrayList<>();
        group1.add("张三");
        group1.add("李四");
        group1.add("王五");
        group1.add("赵六");

        ArrayList<String> group2 = new ArrayList<>();
        group2.add("小刚");
        group2.add("小轩");
        group2.add("小张");
        group2.add("小李");

        map.put(1,group1);
        map.put(2,group2);

        Set<Map.Entry<Integer, ArrayList<String>>> entries = map.entrySet();
        for(Map.Entry<Integer,ArrayList<String>> entry :entries){
            System.out.println(entry.getKey()+"组成员："+entry.getValue());
        }

        Scanner input = new Scanner(System.in);
        System.out.print("请输入你要查询的学员姓名：");
        String findName = input.next();
        boolean flag = false;
        Collection<ArrayList<String>> values = map.values();
        for (ArrayList<String> value : values) {
            if(value.contains(findName)){
                flag = true;
                break;
            }
        }

        if(flag){
            System.out.println(findName + "在本班");
        }else{
            System.out.println(findName + "不在这个班");
        }
        input.close();

    }
}
